<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function getRandom(N, M) {
        return Math.floor(Math.random() * (M - N + 1)) + N
      }
      let res = getRandom(1, 100)
      document.write(res)

      while (true) {
        let num = +prompt('请输入一个数字')
        if (num > res) {
          alert('猜大了')
        }
        if (num < res) {
          alert('猜小了')
        }
        if (num === res) {
          alert('牛逼啊  猜对了')
          break
        }
      }
    </script>
  </body>
</html>
